//
//  TRAdsWebController.m
//  WeiMiLan
//
//  Created by Mac on 15/11/6.
//  Copyright © 2015年 Mac. All rights reserved.
//

#import "TRAdsWebController.h"

@interface TRAdsWebController () <UIWebViewDelegate>
@property (weak, nonatomic) UIWebView *webView;

@end

@implementation TRAdsWebController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self initNavigation];
    
    UIWebView *webView = [[UIWebView alloc]init];
    webView.frame = self.view.frame;
    webView.y = CGRectGetMaxY(self.weChatNavigationBar.frame) + 1;
    webView.height = self.view.height - webView.y - 2;
    [self.view addSubview:webView];
    self.webView = webView;
    self.webView.scalesPageToFit = YES;
    self.webView.delegate = self;
    
    NSURL *url = [NSURL URLWithString:self.adsUrl];
    NSURLRequest *req = [[NSURLRequest alloc]initWithURL:url];
    [self.webView loadRequest:req];
    
    // Do any additional setup after loading the view.
}

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:YES];
    TRTabBarViewController * tabVC =(TRTabBarViewController*) self.tabBarController;
    self.tabBarController.tabBar.hidden =YES;
    tabVC.customTabBarView.hidden = YES;


}

- (void)webViewDidStartLoad:(UIWebView *)webView {
    [MBProgressHUD showMessage:@"加载中..."];
}
- (void)webViewDidFinishLoad:(UIWebView *)webView {
    [MBProgressHUD hideHUD];
}
- (void)initNavigation
{
    [self.navigationController setNavigationBarHidden:YES animated:YES];
    self.weChatNavigationBar=[[WeChatNavigationBar alloc] init];
    [self.view addSubview:self.weChatNavigationBar];
    
   // self.weChatNavigationBar.titleLabel.text=@"发表内容";
    [self.weChatNavigationBar.leftButton addTarget:self action:@selector(exitHomePage) forControlEvents:UIControlEventTouchUpInside];
    self.weChatNavigationBar.leftButton.hidden = NO;
    self.weChatNavigationBar.rightButton.hidden = YES;

}

- (void)exitHomePage {
    [self.navigationController popViewControllerAnimated:YES];
    TRTabBarViewController * tabVC =(TRTabBarViewController*) self.tabBarController;
    self.tabBarController.tabBar.hidden =YES;
    tabVC.customTabBarView.hidden = NO;
}

@end
